package com.mayikt.controller;

import ch.qos.logback.classic.AsyncAppender;
import com.mayikt.utils.LogBlockingQueue;
import com.mayikt.utils.LogException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName PayController
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
@RestController
@Slf4j
public class PayController {
    /**
     * toPay
     *
     * @return
     */
    @RequestMapping("/toPay")
    public String toPay(String payId, String payMoney) {
        // 记录日志到硬盘
        String payLog = System.currentTimeMillis() + "," + payId + "," + payMoney;
        boolean result = LogBlockingQueue.addLog(payLog);
        if (!result) {
            LogException.writeErrorMsg(payLog);
        }
        //直接业务线程写日志文内容
//        LogException.writeErrorMsg(payLog);
        log.info("采用业务线程同步方式写入日志:{}", payLog);
        return "success";
    }

    public static void main(String[] args) {

    }
}
